<%--
  Created by IntelliJ IDEA.
  User: DELL
  Date: 2020/11/13
  Time: 19:32
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<html>
<head>
    <title>新增超管</title>
    <style type="text/css" rel="stylesheet">
        body{
            font-family: "楷体";
            font-size: 16px;
        }
        .all{
            width: 1100px;
            max-height: 450px;
            overflow: auto;
            border: 2px solid rgb(97,166,0);
            margin: 0 auto;
            padding: 50px 30px;
            box-sizing: border-box;
        }
        .yheader{
            font-size: 18px;
            font-weight: 600;
            color: rgb(97,166,0);
            margin-bottom: 10px;
        }
        table{
            width: 600px;
            margin: 0 auto;
        }
        td{
            text-align: center;
        }
        a{
            color: rgb(97,166,0);
            text-decoration: none;
            font-family: "楷体";
            font-weight: 600;
        }
        a:hover{
            color: red;
        }
    </style>
    <script src="/WebContent/JQuery/jquery-3.4.1.js" type="text/javascript"></script>
</head>
<body>
    <article class="all">
        <div class="yheader">当前位置&nbsp;&gt;&gt;&nbsp;添加超级管理员</div>
        <table border="1">
            <tr>
                <th>编号</th>
                <th>用户名</th>
                <th>邮箱地址</th>
                <th>注册时间</th>
                <th>类型</th>
                <th>操作</th>
            </tr>
            <c:forEach items="${requestScope.alladmins}" var="admin" varStatus="status">
                <tr>
                    <td style="display: none" class="id">${admin.adminId}</td>
                    <td>${status.count}</td>
                    <td>${admin.adminUsername}</td>
                    <td>${admin.adminEmail}</td>
                    <td>${admin.adminRegisterTime}</td>
                    <td class="type">${admin.adminRoleType==1?"超管":"普管"}</td>
                    <td><a href="javascript:void(0);" class="swcj">升为超管</a></td>
                </tr>
            </c:forEach>
        </table>
    </article>
    <script>
        $(document).ready(function () {
            $(".swcj").click(function () {
                if(confirm("确定升级超管吗？")){
                    var id = $.trim($(this).parent().siblings(".id").text());
                        $.ajax({
                            url:"/SuperAdminServlet?type=shengji",
                            type:"get",
                            data:{"id":id},
                            dataType:"text",
                            async:true,
                            success:function (data) {
                                if(data == "1"){
                                    alert("操作成功！");
                                    window.location.reload();
                                }else{
                                    alert("操作失败，稍后重试！");
                                }
                            },
                            error:function (error) {
                                alert("系统异常！");

                            }
                        })
                    }else
                        return false;
            })
        })
    </script>
</body>
</html>
